package com.dome.mvp.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.dome.mvp.MyApplication;


/**
 * Time: 4/30/2021 9:47
 * Author: TAO
 * Description: 网络工具类
 */
public class NetworkUtils {

    /**
     * 获取网络管理类
     *
     * @return 返回网络信息
     */
    private static NetworkInfo getNetworkInfo() {
        ConnectivityManager manager = (ConnectivityManager) MyApplication.getApp().getSystemService(Context.CONNECTIVITY_SERVICE);
        return manager.getActiveNetworkInfo();
    }


    /**
     * 网络是否连接
     *
     * @return true无网络链接 false有网络链接
     */
    public static boolean isConnected() {
        return !getNetworkInfo().isConnected();
    }

}
